import { Navigate } from 'react-router-dom'
import { useSelector} from 'react-redux'

//路由守卫
const AuthRoute = ({ children  })=>{
  const token = useSelector((state:any)=>state.user.userInfo.token)
  if (token && token !==''){
    return <>{children}</>
  }else{
    return <Navigate to="/login" replace />
  }
}

export default AuthRoute